import axios from '@/utils/request';

// 获取首页信息
const homePage = params => {
  return axios.get('/homePage', {
    params
  });
};

// 消费排名
const getRankList = params => {
  return axios.get('/v2/costRank', {
    params
  });
};


// 获取用户信息
const getMemberInfo = params => {
  return axios.get('/v2/currentUser', {
    params
  });
};

// 获取首页公告栏目
const getNoticeList_v2 = params => {
  return axios.get('/v2/notices', {
    params
  });
};


// 根据code获取用户信息
const getUserByCode = data => {
  return axios.get('/v2/getUserByCode?code='+data);
};
// 降级
const agentDowngrade = data => {
  return axios.post('/v2/agentDowngrade', data);
};
// 修改备注
const updateMemberRemark = data => {
  return axios.post('/v2/updatePartnerRemark', data);
};

// 获取客户列表
const getMemberList = params => {
  return axios.get('/v2/getCustomers', {
    params
  });
};

// 客户详情
const getMemberDetail = params => {
  return axios.get('/v2/getCustomersDetail/'+params);
};

// 充值算力券
const addVoucherMoney = data => {
  return axios.post('/v2/transferVoucher', data);
};


// 管理员划拨或者赠送算力券
const addVoucher = data => {
  return axios.post('/v2/transferVoucher', data);
};

// 划转时计算伙伴的收入所需要参数
const getPartnerParams = params => {
  return axios.get('/v2/partnerRealDiscountRatio',{params});
};

// 查询伙伴
const checkPartner = params => {
  return axios.get('/checkPartner', {
    params
  });
};

// 调整归属
const changePartner = data => {
  return axios.post('/v2/changePartner', data);
};

// 根据代理商账号查询代理商信息
const getAgentInfo = params => {
  return axios.get('/v2/getPartner/'+params);
};

// 获取订单列表
const getOrderList = params => {
  return axios.get('/v2/getOrderList', {
    params
  });
};

// 获取订单详情
const getOrderDetail = params => {
  return axios.get('/v2/getOrderDetail/',{params});
};

// 获取激励账单
const getIncentiveList = params => {
  return axios.get('/getIncentiveList', {
    params
  });
};
 
// 导出激励账单
const incentiveExport = params => {
  return axios.get('/incentiveExport', {
    params
  });
};

// 获取激励详情
const getIncentiveDetail = params => {
  return axios.get('/getIncentiveDetail', {
    params
  });
};

// 获取伙伴列表
const getPartnerList = params => {
  return axios.get('/v2/partnerList', {
    params
  });
};

// 二代列表
const getPartnerListV2 = params => {
  return axios.get('/v2/childPartners', {
    params
  });
};
// /api/v2/transferVoucher

// 获取伙伴详情
const getPartnerDetail = params => {
  return axios.get('/v2/partnerDetail/'+params);
};

// 生成邀请码
const getInviteLink = params => {
  return axios.get('/v2/generateInviteCode/'+params);
};

// 增加伙伴
const addPartner = data => {
  return axios.post('/v2/addPartner', data);
};

// 获取政策列表
const getPolicySettingList = params => {
  return axios.get('/v2/getPolicySettingList', {
    params
  });
};
// 收益账单
const getBillRecord = params => {
  return axios.get('/v2/income', {
    params
  });
};
// 收益账单详情
const getBillRecordDetail = params => {
  return axios.get('/v2/getBillDetail/'+params);
};
// 新增政策
const savePolicySetting = data => {
  return axios.post('/savePolicySetting', data);
};

// 修改政策
const updatePolicySetting = data => {
  return axios.post('/v2/savePolicySetting', data);
};

// 删除政策
const removePolicySetting = data => {
  return axios.post('/v2/removePolicySetting', data);
};

// 获取公告列表
const getNoticeList = params => {
  return axios.get('/v2/notices', {
    params
  });
};

// 新增公告
const saveNotice = data => {
  return axios.post('/v2/saveNotice', data);
};

// 更新公告
const updateNotice = data => {
  return axios.post('/updateNotice', data);
};

// 删除公告
const removeNotice = data => {
  return axios.post('/v2/removeNotice/'+data);
};

// 获取消息列表
const getMessageList = params => {
  return axios.get('/v2/messages', {
    params
  });
};

// 获取消息详情
const getMessageById = params => {
  return axios.get('/v2/message/'+params);
};

// 消息已读
const redMessage = data => {
  return axios.post('/redMessage', data);
};

// 获取日志列表
const getOperateLogList = params => {
  return axios.get('/v2/getOperateLogList', {
    params
  });
};

// 修改信息获取验证码
const sendUpdateVerifyCode = data => {
  return axios.post('/sms/sendUpdateVerifyCode', data);
};

// 获取算力券列表
const getVoucherList = params => {
  return axios.get('/v2/getVoucherList', {
    params
  });
};

// 导出算力券账单
const voucherExport = params => {
  return axios.get('/v2/exportOrderList', {
    params
  });
};

// 调整等级
const changeLevel = data => {
  return axios.post('/changeLevel', data);
};

// 调整折扣
const changeDiscountRatio = data => {
  return axios.post('/v2/setDiscountRatio', data);
};

// 调整激励
const changeIncentiveRatio = data => {
  return axios.post('/changeIncentiveRatio', data);
};

// 问题咨询
const getQuestion = params => {
  return axios.get('/getQuestion', {
    params
  });
};

// 数据看板
const getDataBoard = params => {
  return axios.get('/v2/dashboard', {
    params
  });
};

// 获取配置信息
const getConfig = params => {
  return axios.get('/v2/getConfig', {
    params
  });
};

// 获取顾客的算力券划拨数据
const customerTransferVoucher = params => {
  return axios.get('/v2/customerTransferVoucher',{
    params
  });
};

// // 获取伙伴的折扣范围
// const getPartnerDiscountRange = params => {
//   return axios.get('/v2/partnerDiscountRatioRange/'+params);
// };

// 删除部分消息
const delMessage = data => {
  return axios.post('/v2/delMessage', data);
};
// 删除全部消息
const delAllMessage = data => {
  return axios.post('/v2/delAllMessage', data);
};

// 标记全部已读
const readAllMessages = data => {
  return axios.post('/v2/readAllMessages', data);
};

// 标记已读
const readMessage = data => {
  return axios.post('/v2/readMessages', data);
};

// 客户消费列表
const userPayments = params => {
  return axios.get('/v2/userPayments', { params });
}


export {
  userPayments,
  readMessage,
  readAllMessages,
  delAllMessage,
  delMessage,
  homePage,
  getConfig,
  getDataBoard,
  getPartnerListV2,
  customerTransferVoucher,
  // getPartnerDiscountRange,
  getRankList,
  getAgentInfo,
  getNoticeList_v2,
  getMemberInfo,
  getUserByCode,
  getMemberList,
  getMemberDetail,
  addVoucherMoney,
  addVoucher,
  getPartnerParams,
  getPartnerDetail,
  checkPartner,
  changePartner,
  getOrderList,
  getOrderDetail,
  getIncentiveList,
  incentiveExport,
  getIncentiveDetail,
  getPartnerList,
  getInviteLink,
  addPartner,
  getPolicySettingList,
  savePolicySetting,
  updatePolicySetting,
  removePolicySetting,
  getNoticeList,
  saveNotice,
  updateNotice,
  removeNotice,
  getMessageList,
  getMessageById,
  redMessage,
  getOperateLogList,
  sendUpdateVerifyCode,
  getVoucherList,
  voucherExport,
  changeLevel,
  changeDiscountRatio,
  changeIncentiveRatio,
  getQuestion,
  agentDowngrade,
  updateMemberRemark,
  getBillRecord,
  getBillRecordDetail
};
